package standards.huawei.obj;

public class Standards_Huawei_OBJ_02_Case2 {
    public static void main(String[] args) {
        try {
            JuniorClass jun = new JuniorClass();
            System.out.println(jun.toString());
        } catch (Exception ex) {
            System.out.println("Get error:" + ex.getMessage());
        }
    }
}

class SeniorClass {
    public SeniorClass() {
       toString(); // 如果toString()被覆写了，可能会导致异常
    }

    @Override
    public String toString() {
        return "IAmSeniorClass";
    }
}

class JuniorClass extends SeniorClass {
    private String name;

    public JuniorClass() {
        super(); // 调用父类的构造方法，导致NullPointerException异常
        name = "JuniorClass";
    }

    @Override
    public String toString() {
        return name.toUpperCase();
    }
}